<?php

/**
 * Customer form base class.
 *
 * @method Customer getObject() Returns the current form's model object
 *
 * @package    Serag
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseCustomerForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'               => new sfWidgetFormInputHidden(),
      'customer_name'    => new sfWidgetFormInputText(),
      'shipping_address' => new sfWidgetFormInputText(),
      'email'            => new sfWidgetFormInputText(),
      'is_deleted'       => new sfWidgetFormInputText(),
      'title_id'         => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Title'), 'add_empty' => false)),
      'billing_address'  => new sfWidgetFormInputText(),
      'payment_method'   => new sfWidgetFormChoice(array('choices' => array('cash' => 'cash', 'cheque' => 'cheque', 'open account' => 'open account'))),
      'payment_history'  => new sfWidgetFormChoice(array('choices' => array('poor' => 'poor', 'good' => 'good', 'excellent' => 'excellent'))),
      'notes'            => new sfWidgetFormTextarea(),
    ));

    $this->setValidators(array(
      'id'               => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id')), 'empty_value' => $this->getObject()->get('id'), 'required' => false)),
      'customer_name'    => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'shipping_address' => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'email'            => new sfValidatorString(array('max_length' => 100, 'required' => false)),
      'is_deleted'       => new sfValidatorInteger(array('required' => false)),
      'title_id'         => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Title'))),
      'billing_address'  => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'payment_method'   => new sfValidatorChoice(array('choices' => array(0 => 'cash', 1 => 'cheque', 2 => 'open account'), 'required' => false)),
      'payment_history'  => new sfValidatorChoice(array('choices' => array(0 => 'poor', 1 => 'good', 2 => 'excellent'), 'required' => false)),
      'notes'            => new sfValidatorString(array('required' => false)),
    ));

    $this->widgetSchema->setNameFormat('customer[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Customer';
  }

}
